package com.xyy.saas.payment.adpater.fumin.config;

import com.xyy.saas.payment.dao.model.FmBankCode;
import com.xyy.saas.payment.service.FmBankCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author wangtianqi
 * @date 2020/9/1 14:42
 */
@Component(value = "fuminBankCodeConfig")
public class FuminBankCodeConfig {

    @Autowired
    private FmBankCodeService fmBankCodeService;

    public String getBankCodeByName(String bankName) {
        return fmBankCodeService.queryCodeByName(bankName);
    }

    public Map<String, String> getBankMap() {
        List<FmBankCode> fmBankCodes = fmBankCodeService.queryAll();
        return fmBankCodes.stream().collect(Collectors.toMap(FmBankCode::getName, FmBankCode::getCode));
    }

}